import 'package:flutter/foundation.dart' show kIsWeb;
import 'dart:io' show Platform;
import '../utils/platform_checker.dart';
import 'url_service_mobile.dart';
import 'url_service_web.dart';
import 'phone_service_mobile.dart';
import 'phone_service_web.dart';

/// 服务工厂类，根据平台返回对应的服务实现
class ServiceFactory {
  // URL服务
  static Future<void> openUrl(String url) async {
    if (PlatformChecker.isWeb) {
      UrlServiceWeb.openUrl(url);
    } else {
      await UrlServiceMobile.openUrl(url);
    }
  }

  // 电话服务
  static Future<bool> callPhone(String phoneNumber) async {
    if (PlatformChecker.isWeb) {
      return PhoneServiceWeb.callNumber(phoneNumber);
    } else {
      return await PhoneServiceMobile.callNumber(phoneNumber);
    }
  }
}
